package com.example.demo.controller;

import com.example.demo.pojo.*;
import com.example.demo.service.ClazzService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.function.ToDoubleBiFunction;

@RestController
@Slf4j
@RequestMapping("/clazzs")
public class ClazzController {
    @Autowired
    private ClazzService clazzService;

@GetMapping()
    public Result list(ClazzQueryParam clazzQueryParam) {
    log.info("查询请求参数：",clazzQueryParam);
    PageResult pageResult = clazzService.page(clazzQueryParam);
    return Result.success(pageResult);
}
@DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id)
{
    log.info("删除请求参数: ",id);
    clazzService.delete(id);
    return Result.success();

}
@PostMapping()
    public Result save(@RequestBody Clazz clazz)
{
    log.info("添加请求参数",clazz);

    clazzService.save(clazz);
    return Result.success();
}

@GetMapping("/{id}")
    public  Result find(@PathVariable Integer id)
{
    log.info("添加搜索参数",id);

    Clazz c=    clazzService.find(id);

   return Result.success(c);

}
@PutMapping()
    public  Result update(@RequestBody Clazz clazz)
{
                    clazzService.update(clazz);

    return  Result.success();
}
@GetMapping("/list")
    public  Result findall(){

    List<Clazz> c= clazzService.findall();

    return Result.success(c);
}
}



